<?php

namespace Backend\Model;
use Think\Model;

class FinanceModel extends  Model
{
    public function delivery_consum($pageSize = 10) {


        $where = array();
        $count = $this->alias('a')->where($where)->count();
        $page = new \Think\Page($count, $pageSize);
        // 配置翻页的样式
        $page->setConfig('prev', '上一页');
        $page->setConfig('next', '下一页');
        $data['page'] = $page->show();
        /************************************** 取数据 ******************************************/

        $data['data'] = $this->alias('a')
            ->field('a.id,a.ad_name as delivery_name,a.use_amount,sum(b.amount) as amount,sum(b.total_amount) as total_amount ,b.order_name ,m.username as customer_name')
            ->join('dsp_ad_order AS b ON a.order_id=b.id','LEFT')
            ->join('dsp_admin AS m ON a.user_id = m.id','LEFT')
            ->where($where)
            ->order('a.id desc')
            ->group('a.id')
            ->limit($page->firstRow.','.$page->listRows)
            ->select();
        return $data;
    }
}